package game.display;

import java.awt.Graphics;
import java.awt.Image;

import game.menu.Drawable;

public class Star implements Drawable{
	private double dx;
	private double dy;
	private double x;
	private double y;
	
	private Animation star;
	
	public Star(double x, double y, double dx, double dy){
		this.dx = dx;
		this.dy = dy;
		this.x = x;
		this.y = y;
		this.star = Images.STAR.image();
	}
	
	public void update(){
		x += dx;
		y += dy;
		if (x + 64 < 0){
			x = Background.getWidth();
			dx = (1 - 2*Math.random());
		}
		if (x > Background.getWidth()){
			x = -64;
			dx = (1 - 2*Math.random());
		}
		if (y + 64 < 0){
			y = Background.getHeight();
			dy =(1 - 2*Math.random());
		}
		if (y > Background.getHeight()){
			y = -64;
			dy = (1 - 2*Math.random());
		}
	}

	@Override
	public void draw(Graphics g) {
		g.drawImage(star.getImage(), (int)x, (int)y, null);
	}

}
